﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Script.Services;
using System.Web.Script.Serialization;

/// <summary>
/// Summary description for BusService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
 [System.Web.Script.Services.ScriptService]
public class BusService : System.Web.Services.WebService {

    public BusService () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }
    [WebMethod]
    public District[] loadDistrictList()
    {
        return Data.districts.ToArray();
    }
    [WebMethod]
    public Station[] loadAllStationList()
    {
        return Data.stations.Where(p=>p.DistrictName=="Bình Thạnh").ToArray();
    }
    [WebMethod]
    public Station[] loadAllStationToDraw()
    {
        return Data.stations.Where(p => p.Longitude != 0 && p.DistrictName == "Bình Thạnh").ToArray();
    }
    [WebMethod]
    public string upDateStation(int IDStation, string addressNumber, string street, string district,  float latitude,float longitude)
    {
        return Data.upDateStation(IDStation, addressNumber, street, district, longitude, latitude);
    }
    [WebMethod]
    public Station getStationInfo(int IDStation)
    {
        return Data.stations.SingleOrDefault(station => station.IDStation == IDStation);
    }
    [WebMethod]
    public string insertStation(string addressNumber, string street, string district, float latitude, float longitude)
    {
              return Data.insertStation(addressNumber, street, district, longitude, latitude);
    }
    [WebMethod]
    public double calulateLengthofNodes(string nodes)
    {
        return Data.calulateLengthofNodes(nodes);
    }
    [WebMethod]
    public string updateStationToStation(int id1, int id2, string nodes)
    {
        return Data.updateStationToStation(id1, id2, nodes);
    }
    [WebMethod]
    public bool insertStationToStation(int id1, int id2)
    {
        return Data.insertStationToStation(id1, id2);
    }
    [WebMethod]
    public string[] getWayStationToOtherStation(int id1)
    {
        return Data.getWayStationToOtherStation(id1);
    }
    [WebMethod]
    public StationToStation[] getStationToStation(int idBegin)
    {
        return Data.getStationToStation(idBegin);
    }
    [WebMethod]
    public StationToStation getStationToStationDetail(int idBegin, int idEnd)
    {
        return Data.getStationToStation(idBegin, idEnd);
    }
    [WebMethod]
    public bool insertBusRoute()
    {
       return Data.insertBusRoute();
    }
    [WebMethod]
    public bool updateBusRoute(int idBusRoute, string name, string stations, string number)
    {
        return Data.updateBusRoute(idBusRoute, name, stations, number);
    }
    [WebMethod]
    public string getBusRouteToDraw(int id)
    {
        return Data.getBusRouteToDraw(id);
    }
    [WebMethod]
    public BusRoute getBusRoute(int id)
    {
        return Data.getBusRoute(id);
    }
    [WebMethod]
    public BusRoute[] getBusRoutes()
    {
        return Data.getBusRoutes();
    }
    [WebMethod]
    public string[] findPathBetweenTwoStation(int idStation1, int idStation2, double walk, double changeRoute)
    {
        return Data.findPathBetweenTwoStation(idStation1, idStation2, walk, changeRoute);
    }
    [WebMethod]
    public string[] findPathBetweenTwoStation1(double longitude1, double latitude1, double longitude2, double latitude2, double walk, double changeRoute)
    {
        return Data.findPathBetweenTwoStation(longitude1, latitude1, longitude2, latitude2, walk, changeRoute);
    }
}
